#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75582-staprun.sh
# Version:    1.0
# Date:       2013/12/03
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    02系统基本功能-07开发环境-02开发工具-07SystemTap-02运行staprun命令
# Notes:      staprun命令
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/03
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh

source ../../lib/XmlParse.sh


function CleanData ()
{
  rm -rf mod1.ko
  EchoInfo "75582-staprun.sh执行完毕"
}

trap "CleanData" EXIT INT

stap -p4 -m mod1 -e 'global var1="foo";probe begin{printf("%s\n",var1);exit()}'
ls mod1.ko
EchoResult "运行stap命令，生成mod1.ko文件"

[ "`staprun mod1.ko`" == "foo" ]
EchoResult "终端输出foo"

[ "`staprun mod1.ko var1='HelloWorld'`" == "HelloWorld" ]
EchoResult "终端输出HelloWorld"
